package com.me.libgdx_test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class ClassPlayerPickupMod {
	//Modifiers for when things are picked up
	//Blood Pool Bonuses: 5 pools extra life, heal 10%, 4 gold, increase random levelup bonuses
	//General pickups: +5 from attack pickup, mana item converts to health item
	//String blood_bonus;
	String general_bonus;
	int extra_life;
	boolean mana_health = false;
	int attack_bonus = 2;
	ArrayList<String> blood_bonus;
	Random random = new Random(System.currentTimeMillis());
	ClassPlayerPickupMod(String general_bonus, String...blood_bonus){
		//this.blood_bonus = blood_bonus;
		this.blood_bonus = new ArrayList<String>(Arrays.asList(blood_bonus));
		this.general_bonus = general_bonus;
		extra_life = 0;
	}
	public void use_item(){
		if(general_bonus.equals("+5_atk")){
			attack_bonus = 5;
		}
		if(general_bonus.equals("mana=>health")){
			mana_health = true;
		}
	}
	public boolean use_blood_pool(ClassCharacterPlayer player){
		boolean use_blood_pool = false;
		for(String bonus:blood_bonus){
			if(bonus.equals("5_life")){
				if(extra_life == 5 && !player.get_contracted_mod("Extra Life")){
					player.set_contracted_mod("Extra Life", true);
					extra_life=0;
					use_blood_pool = true;
				}else if(extra_life < 5 && !player.get_contracted_mod("Extra Life")){
					extra_life++;
					use_blood_pool = true;
				}
			}
			if(bonus.equals("heal_5%")){
				player.set_player_variable("current_health", player.get_player_variable("current_health") + ((int) (player.get_max_health()*.05)));
				use_blood_pool = true;
			}
			if(bonus.equals("heal_50%")){
				player.set_player_variable("current_health", player.get_player_variable("current_health") + ((int) (player.get_max_health()*.5)));
				use_blood_pool = true;
			}
			if(bonus.equals("heal_10%")){
				player.set_player_variable("current_health", player.get_player_variable("current_health") + ((int) (player.get_max_health()*.1)));
				use_blood_pool = true;
			}
			if(bonus.equals("4_gold")){
				player.set_player_variable("gold", player.get_player_variable("gold")+4);
				use_blood_pool = true;
			}
			if(bonus.equals("random_increase")){
				switch(random.nextInt(3)){
					case 0:player.get_class_mods().playerAttMod.levelup_increases[0] += 1;break;
					case 1:player.get_class_mods().playerAttMod.levelup_increases[1] += 1;
					case 2:player.get_class_mods().playerAttMod.levelup_increases[2] += 1;
					default:player.get_class_mods().playerAttMod.levelup_increases[0] += 1;break;
				}
				use_blood_pool = true;
			}
		}
		return use_blood_pool;
	}
}
